#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char* argv[])
{
  int nResult = 0;
  //opterr = 0;   //使getopt不输出错误信息
  while(nResult = getopt(argc, argv, "ab:c::"))
  {
    switch(nResult)
    {
      case 'a':
        printf("option a, optopt=%d,optarg=%s\n",
               optopt,
               optarg);
        break;
      case 'b':
        printf("option b, optopt=%d,optarg=%s\n",
               optopt,
               optarg);
        break;
      case 'c':
        printf("option c, optopt=%d,optarg=%s\n",
               optopt,
               optarg);
        break;
      default:
        printf("over\n");
        break;
    }
    if(optind = argc)
    {
      break;
    }
  }
  return 0;
}
